package com.core.common.listener;

import javax.annotation.Resource;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;

import com.core.common.service.IInitDataService;

@Service
public class InitDataListener implements ApplicationListener<ContextRefreshedEvent>{


	@Resource
	private IInitDataService initDataService;
	private static volatile boolean flag = false;
	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		if(event.getApplicationContext().getParent() == null){
			if(!flag){
				flag=true;
				initDataService.initDataBase();
			}
		}
	}

	

}
